{% extends "default.html" %}

{% load i18n %}
{% load jalali_view %}

{% block title %} {{ object.title }} {% endblock %}

{% block page_content %}
{% if warning %}
<div class="span-10" style="color: orange;">{{ warning }}</div>
{% endif %}
{% if not object.enabled %}
<div class="span-10" style="background-color: #990000; color: #fff">
{% trans "This ad is not published." %}
</div>
{% endif %}
<div class="span-10">
<h3>{% trans "Ad" %} - {{ object.title }}</h3>

<h5>{% trans "Registration Date" %}</h5>
<span>{% jalali_view object.registration_date %}</span>

<h5>{% trans "Publish Start Date" %}</h5>
<span>{% jalali_view object.start_date %}</span>

<h5>{% trans "Publish End Date" %}</h5>
<span>{% jalali_view object.end_date %}</span>

<h5>{% trans "Description" %}</h5>
<p>{{ object.description }}</p>

<h5>{% trans "Advertizer" %}</h5>
<p>
<a href="/ads/explore/advertizer/{{ object.advertizer.id }}/">
{{ object.advertizer }}
</a>
</p>

{% ifnotequal None object.url %}
<h5>{% trans "URL Address" %}</h5>
<p><a href="{{ object.url }}" target="_blank">{{ object.url }}</a></p>
{% endifnotequal %}

<h5>{% trans "Tags" %}</h5>
<p>
{% for at in adtags %}
<span><a href="/ads/tag/explore/{{at.term.id}}">{{ at.term }}</a></span>&nbsp;
{% endfor %}
</p>

<div>
<a id="ad_like_link" href="#">{% trans "Thumbs Up" %}</a> 
<span id="ad_likes">({{ likes }})</span>
<script type="text/javascript">
$("#ad_like_link").click(function () {
	$.getJSON("/ads/like/{{ object.id }}", function(data) {
		$("#ad_likes").text("(" + data + ")");
	});
});
</script>
&bull;
<a id="ad_dislike_link" href="#">{% trans "Thumbs Down" %}</a> 
<span id="ad_dislikes">({{ dislikes }})</span>
<script type="text/javascript">
$("#ad_dislike_link").click(function () {
	$.getJSON("/ads/dislike/{{ object.id }}", function(data) {
		$("#ad_dislikes").text("(" + data + ")");
	});
});
</script>
</span>
</div>
<div>
{% trans "View Count" %}: <br/> {{ count_views }}
</div>
{% if last_viewed %}
<div>
{% trans "Last Viewed" %}: <br/> {% jalali_view last_viewed %}
</div>
{% endif %}
</div>

{% if other_ads|length > 0 %}
<div class="span-8 last">
<h3 class="loud">{% trans "Other Ads By" %}: {{ object.advertizer }}</h3>
<hr/>
{% for ad in other_ads %}
<div class="span-8">
{% include "ad/ad_box.html" %} 
</div>
<br/>
{% endfor %}
</div>
{% endif %}
<br />
{% if related_ads|length > 0 %}
<div class="span-8 last">
<h3 class="loud">{% trans "Related Ads" %}</h3>
<hr/>
{% for ad in related_ads %}
<div class="span-8">
{% include "ad/ad_box.html" %} 
</div>
<br/>
{% endfor %}
</div>
{% endif %}

{% endblock page_content %}
